<template>
  <div class="list-container">
    <!-- <van-tabs v-model="queryObj.sort" @change="tabChange">
      <van-tab title="默认排序" name></van-tab>
      <van-tab title="销量优先" name="1"></van-tab>
      <van-tab title="价格优先" name="4"></van-tab>
    </van-tabs> -->
    <div class="main-container">
      <div class="main-item" v-for="(item, index) in List" :key="index" @click="details(item)">
        <div class="left-container">
          <img :src="imgUrl + item.indexpic" alt />
        </div>
        <div class="right-container">
          <div class="name">{{ item.title }}</div>
          <div class="num">已兑换 {{ item.sold + item.soldinit }}</div>
          <div class="footer">
            <div class="price">积分 {{item.price}}</div>
            <div class="btn">立即兑换</div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      total: 0,
      List: []
    };
  },
  computed: {
    imgUrl() {
      return this.$imgUrl;
    },
    userInfo() {
      return this.$store.state.userData;
    }
  },
  created() {
    this.getList();
  },
  methods: {
    async getList() {
      const result = await this.$fetchGet('/home/index/integral');
      this.List = result.data.list
    },
    details (item) {
      this.$router.push({
        path: "/shopping/details",
        query: {
          type: 'integral',
          id: item.id
        }
      });
      console.log(item)
    }
  }
};
</script>

<style lang="scss">
.list-container {
  .main-container {
    max-height: calc(100vh - 80px);
    overflow-y: auto;
    background: #ffffff;
    .main-item {
      display: flex;
      padding: 20px;
      box-sizing: border-box;
      border-bottom: 1px solid #d8d8d8;
      .left-container {
        img {
          width: 200px;
          height: 200px;
        }
      }
      .right-container {
        flex: 1;
        margin-left: 50px;
        display: flex;
        flex-direction: column;
        .name {
          font-size: 30px;
          font-weight: 600;
          flex: 1;
        }
        .num {
          color: #929292;
          font-size: 25px;
          margin-bottom: 5px;
        }
        .footer {
          display: flex;
          .price {
            font-size: 30px;
            font-weight: bold;
            color: #ff3b3b;
            flex: 1;
          }
          .btn {
            width: 180px;
            height: 60px;
            color: #fff;
            font-weight: bold;
            border-radius: 60px;
            text-align: center;
            line-height: 60px;
            background: linear-gradient(to right, #fc8f04, #f71c19);
          }
        }
      }
    }
  }
}
</style>